package com.t235.gc.entity;

import lombok.Data;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;
@Data
public class SysManager implements Serializable, UserDetails {
    private String managerid;

    private String username;

    private String contactname;

    private String userphone;

    private String useraccount;

    private String password;

    private String androidpassword;

    private String managerpic;

    private Integer managertype;

    private String fid;

    private BigDecimal garbagerecyclingcomrate;

    private BigDecimal homerecyclingcomrate;

    private BigDecimal goodscomrate;

    private String remark;

    private Integer isflag;

    private Integer isdel;

    private Date ctime;

    private List<SysRole> roles = new ArrayList<>();

    public Collection<? extends GrantedAuthority> getAuthorities() {
        List<SimpleGrantedAuthority> authorities=new ArrayList<>();
        roles.forEach(role ->{
            authorities.add(new SimpleGrantedAuthority(role.getRolename()));
        });
        return authorities;
    }

    public boolean isAccountNonExpired() {
        return true;
    }


    public boolean isAccountNonLocked() {
        return true;
    }


    public boolean isCredentialsNonExpired() {
        return true;
    }


    public boolean isEnabled() {
        return true;
    }
}